<template>
  <div>
    <ZgDialog
      :width="view.width"
      :top="view.top"
      :title="view.title"
      :showFooter="true"
      v-model="visible"
      @ok="onOk"
      @cancel="onCancel"
    >
      <div>
        <h3 class="title">画像配置<span>修改后第二天生效配置</span></h3>
        <div class="times flx mb5">
          <span class="title-sub">执行周期</span>
          <ZgSelect
            class="score-max-select"
            :options="executePeriod"
            v-model="time"
            :width="120"
            placeholder="请选择执行周期"
          />
        </div>
        <div v-for="item in list" :key="item.title">
          <div class="times flx mb5">
            <span class="title-sub">{{ item.title }}</span>
            <span>总分合计：{{ item.totalScore }}</span>
          </div>
          <Item
            v-for="ite in item.children"
            :key="ite.label"
            :title="ite.label"
            :scoreOptions="scoreOptions"
            :columnTitle="ite.columnTitle"
            :selectMode="ite.selectMode"
            :dictionaryOption="ite.dictionaryOption"
            :exceedOptions="ite.exceedOptions"
            :initialRows="ite.initialRows"
          ></Item>
        </div>
      </div>
    </ZgDialog>
  </div>
</template>
<script>
// 行业分类
const industryClassifyArr = [
  { label: '教育行业', value: '1' },
  { label: 'IT行业', value: '2' },
  { label: '金融行业', value: '3' }
]
// 次数列表
const timesList = (() => {
  const arr = [1, 5, 10, 15, 20, 30, 40, 50]
  return arr.map((item) => {
    return Object.assign({}, { label: item + '次', value: item })
  })
})()
// 年列表
const yearList = (() => {
  const arr = [10, 7, 5, 3, 2, 1]
  return arr.map((item) => {
    return Object.assign({}, { label: item + '年', value: item })
  })
})()
// %列表
const rateList = (() => {
  const arr = [100, 90, 80, 50]
  return arr
    .map((item) => {
      return Object.assign({}, { label: item + '%以上', value: item })
    })
    .push({ label: '其他', value: 'other' })
})()
// 个列表
const numList = (() => {
  const arr = [10, 20, 30, 40, 50, 60, 80, 100]
  return arr.map((item) => {
    return Object.assign({}, { label: item + '个', value: item })
  })
})()
// 项列表
const itemList = (() => {
  const arr = [1, 5, 10]
  return arr.map((item) => {
    return Object.assign({}, { label: item + '项', value: item })
  })
})()
// 亿列表
const yiList = (() => {
  const arr = ['10亿', '5亿', '1亿', '5000万', '1000万', '500万', '100万']
  return arr
    .map((item) => {
      return Object.assign({}, { label: item, value: item })
    })
    .push({ label: '其他', value: 'other' })
})()
export default {
  components: {
    Item: () => import('../profileBank/Item.vue')
  },
  props: {
    inputClick: {
      type: Function,
      default: (t) => {}
    }
  },
  data() {
    return {
      visible: false,
      view: {
        width: '80%',
        top: '5%',
        title: '平台画像配置'
      },
      obj: null,
      other: {},
      time: undefined,
      executePeriod: [
        { label: '每个月一次', value: 'monthly' },
        { label: '每季度一次', value: 'quarterly' },
        { label: '每年一次', value: 'annually' }
      ],
      // 最高分下拉选项
      scoreOptions: [
        { label: '得分项', value: 'add' },
        { label: '减分项', value: 'subtract' }
      ],
      // 超过列为下拉时的选项
      exceedOptions: [
        { label: '2年', value: '2年' },
        { label: '3年', value: '3年' },
        { label: '5年', value: '5年' }
      ],
      list: [
        {
          title: '基本信息',
          totalScore: 0,
          children: [
            {
              label: '行业分类', // 类别
              columnTitle: '所属分类', // 中间列名
              selectMode: 'multiple', // 选择模式
              dictionaryOption: true, // 是否字典选择
              exceedOptions: industryClassifyArr, // 选择列表项
              initialRows: [] // 初始行数据
            },
            {
              label: '公司性质',
              columnTitle: '所属分类',
              selectMode: 'multiple',
              dictionaryOption: true,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '存续时间',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: yearList,
              initialRows: []
            },
            {
              label: '实缴资本',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: yiList,
              initialRows: []
            },
            {
              label: '信息核查',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: itemList,
              initialRows: []
            }
          ]
        },
        {
          title: '经营信息',
          totalScore: 0,
          children: [
            {
              label: '纳税信用',
              columnTitle: '所属分类',
              selectMode: 'multiple',
              dictionaryOption: true,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '国有土地让受',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: timesList,
              initialRows: []
            },
            {
              label: '抽查问题',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '供应商数',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: numList,
              initialRows: []
            },
            {
              label: '客户数量',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '产权交易',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '资产拍卖',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            }
          ]
        },
        {
          title: '严重违法',
          totalScore: 0,
          children: [
            {
              label: '严重违法',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            }
          ]
        },
        {
          title: '法律风险',
          totalScore: 0,
          children: [
            {
              label: '司法拍卖',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '司法案件',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '被告立案',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '开庭公告',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '终本案件',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            }
          ]
        },
        {
          title: '经营分险',
          totalScore: 0,
          children: [
            {
              label: '行政处罚',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '环保处罚',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '公示催告',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '惩戒名单',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            }
          ]
        },
        {
          title: '知识能力',
          totalScore: 0,
          children: [
            {
              label: '专利信息',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '软件著作',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            }
          ]
        },
        {
          title: '交易结算',
          totalScore: 0,
          children: [
            {
              label: '交易频次',
              columnTitle: '平均每年(近三年)',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '交易金额',
              columnTitle: '平均每年(近三年)',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '交易数量',
              columnTitle: '平均每年(近三年)',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '合作年限',
              columnTitle: '超过',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: industryClassifyArr,
              initialRows: []
            },
            {
              label: '结算率',
              columnTitle: '已完成合同平均结算率(近三年)',
              selectMode: 'default',
              dictionaryOption: false,
              exceedOptions: rateList,
              initialRows: []
            }
          ]
        }
      ],
      // 初始行数据
      initialRows: [{ exceed: '2年', score: 10 }],
      // 网关前缀
      gateWayPrefix: '/zg-scf'
    }
  },
  mounted() {},
  methods: {
    open(json) {
      this.obj = Object.assign({}, this.obj, json || {})
      console.log('获取的行数据', this.obj)
      this.visible = true
    },
    onOk() {
      this.obj = null
      this.visible = false
      this.$emit('ok')
    },
    onCancel() {},
    // 获取画像平台配置
    getPortraitConfig() {
      this.$http.get(`${this.gateWayPrefix}//img/config/getInfo`, { configId: 1 }, (data) => {
        console.log(data)
      })
    }
  },
  created() {
    this.getPortraitConfig()
  }
}
</script>

<style lang="scss" scoped>
.title {
  padding-bottom: 10px;
  font-size: 18px;
  color: #333;
  font-weight: 700;
  span {
    font-size: 14px;
    font-weight: 500;
    float: right;
  }
}
.title-sub {
  font-size: 14px;
  color: #333;
  font-weight: 700;
  min-width: 130px;
  line-height: 30px;
}
</style>
